#include <iostream>
#include <fstream>
#include <string>

int main()
{
	std::string filename = "example.txt";
	std::ofstream outFile(filename, std::ios::out);
	if (!outFile) {
		std::cerr << "can't open file for writing" << std::endl;
		return 1;
	}
	outFile << "Hello, World!" << std::endl;
	outFile << "This is a file writing test" << std::endl;
	outFile.close();

	std::ifstream inFile(filename, std::ios::in);
	if (!inFile) {
		std::cerr << "can't open file for reading" << std::endl;
		return 1;
	}
	std::string line;
	while (std::getline(inFile, line)) {
		std::cout << line << std::endl;
	}
	inFile.close();
	return 0;
}